package edu.hrbu.spring.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Arrays;

/**
 * @author 徐登宇
 */
@Controller
public class HelloController {
    @GetMapping("/")
    public String protal() {
        return "hello";
    }

    @PutMapping("/hello")
    public String hello() {
        return "hello";
    }

    @GetMapping("/forward")
    public String forward() {
        return "forward";
    }

    @GetMapping("/pathVarible/{userName}/{userAge}")
    public String pathVarible(@PathVariable("userName") String name, @PathVariable("userAge") String age) {
        System.out.println("【pathVarible】@ name: " + name + "@ age: " + age);
        return "hello";
    }

    @GetMapping("/requestParam")
    public String requestParam(@RequestParam("userName") String name, @RequestParam("userAge") Integer age) {
        System.out.println("【requestParam】@ name: " + name + "@ age: " + age);
        return "hello";
    }

    @GetMapping("/arr")
    public String arr(@RequestParam("hobby") String[] hobby) {
        System.out.println("【arr】hobby:" + Arrays.toString(hobby));
        return "hello";
    }

}
